import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'

//路由的配置数组
//path: 路由路径 必须以/开头
//name：路由名字
//component：对应的路由组件
const routes = [
  {
    path: '/',
    name: 'home',
    //首页直接引入
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    //按需引入
    //如果没有访问/about 就不会加载这个组件，节约性能
    component: () => import('../views/About.vue')
  }

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
